package org.springblade.modules.system.controller;

import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.modules.system.entity.DoctorCategory;
import org.springblade.modules.system.service.DoctorCategoryService;
import org.springblade.modules.system.utils.PageBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

@Controller
@RequestMapping("/doctorCategory")
public class DoctorCategoryController extends BladeController {

	@Autowired
	private DoctorCategoryService doctorCategoryService;

	@ResponseBody
	@RequestMapping(value = "/openDoctorCategoryTable", method = RequestMethod.POST)
	public HashMap<String, Object> openDoctorCategoryTable(String type, int pageSize, int currentPage) {
		HashMap<String, Object> result = new HashMap<String, Object>();
		PageBounds<DoctorCategory> pageBounds = null;
		try {
			pageBounds = doctorCategoryService.openDoctorCategoryTable(type, currentPage, pageSize);
		} catch (Exception e) {
			e.printStackTrace();
		}
		result.put("data", pageBounds);
		return result;
	}

	/**
	 * 获取全部信息
	 */
	@ResponseBody
	@RequestMapping(value = "/selectAllDoctorCategory", method = RequestMethod.POST)
	public HashMap<String, Object> selectAllDoctorCategory() {
		HashMap<String, Object> result = new HashMap<String, Object>();
		List<DoctorCategory> doctorCategory = doctorCategoryService.selectAllDoctorCategory();
		result.put("data", doctorCategory);
		return result;
	}

	/**
	 * 添加
	 */
	@ResponseBody
	@RequestMapping(value = "/addDoctorCategory", method = RequestMethod.POST)
	public HashMap<String, Object> addDoctorCategory(DoctorCategory doctorCategory) {
		HashMap<String, Object> result = new HashMap<String, Object>();
		doctorCategoryService.addDoctorCategory(doctorCategory);
		return result;
	}

	/**
	 * 修改
	 */
	@ResponseBody
	@RequestMapping(value = "/updateDoctorCategory", method = RequestMethod.POST)
	public HashMap<String, Object> updateDoctor(DoctorCategory doctorCategory) {
		HashMap<String, Object> result = new HashMap<String, Object>();
		doctorCategoryService.updateDoctorCategory(doctorCategory);
		return result;
	}

	/**
	 * 通过id删除
	 */
	@ResponseBody
	@RequestMapping(value = "/deleteDoctorCategoryById", method = RequestMethod.POST)
	public HashMap<String, Object> deleteDoctorCategoryById(Integer id) {
		HashMap<String, Object> result = new HashMap<String, Object>();
		doctorCategoryService.deleteDoctorCategoryById(id);
		return result;
	}

	/**
	 * 通过id多删除
	 *
	 * @param @return
	 * @Title: delStudentById
	 */
	@ResponseBody
	@RequestMapping(value = "/deleteDoctorCategoryByIds", method = RequestMethod.POST)
	public HashMap<String, Object> deleteDoctorCategoryByIds(Integer[] ids) {
		HashMap<String, Object> result = new HashMap<String, Object>();
		doctorCategoryService.deleteDoctorCategoryByIds(Arrays.asList(ids));
		return result;
	}
}
